package com.zsj.controller;

import com.zsj.service.NotifyService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@RestController
@RequestMapping("/notify")
@Slf4j
public class NotifyController {

    @Autowired
    private NotifyService notifyService;

    @RequestMapping(value = "/callback/{name}", method = {RequestMethod.GET, RequestMethod.POST})
    public void callback(@PathVariable("name") String name,
                         HttpServletRequest request,
                         HttpServletResponse response) {
        log.info("收到{}的回调通知", name);
        notifyService.dealNotify(request, response);
    }

}
